
//-------------------------
// Legislators as Lobbyists
// TABLE 1
//-------------------------

clear
use masterdata_county.dta

tabstat totaltaa, stat(N p25 p50 p75) 
gen group = .
replace group = 1 if totaltaa == 0
replace group = 2 if totaltaa > 0 & totaltaa < 4
replace group = 3 if totaltaa >= 4


gen whiteratio = white/pop
gen blackratio = black/pop
gen a1 = white/pop
gen a2 = black/pop
gen a3 = indian/pop
gen a4 = asian/pop
gen a5 = pacific/pop
gen a6 = otherace/pop
gen a7 = tworaces/pop
gen a8 = hispanic/pop
gen ethnic = 1 - (a1^2 + a2^2 + a3^2 + a4^2 + a5^2 + a6^2 + a7^2 +a8^2)
gen nohs = lessthanhs/pop_over25
gen hs = highschool/pop_over25 
gen loweredu = nohs + hs
gen college = bachelor/pop_over25
gen advanced = (master + professional + doctorate)/pop_over25
gen unemployment = civilian_unemployed/civilian
gen male_unemployment = male_umemployed/civilian_male
gen female_unemployment = female_umemployed/civilian_female
gen white_unemployment = whilte_unemployed/whilte_laborforce
gen publicsectorratio = public_sector/employed_civilian
gen manufacturingratio = manufacturing/employed_civilian
gen agricultureratio = agriculture/employed_civilian
gen foreignratio = foreign_born/pop
gen noinsuranceratio = noinsurance/insurance_pop

gen lpop = ln(pop +1)
gen lnpcincome = ln(pcincome+1)

gen repratio08 = gop_2008/(dem_2008 + gop_2008)
gen repratio12 = gop_2012/(dem_2012 + gop_2012)
gen repratio16 = gop_2016/(dem_2016 + gop_2016)

replace rep_primary_trump_vs = rep_primary_trump_vs/100

macro define demographic "lpop whiteratio loweredu lnpcincome unemployment white_unemployment d_tradeusch_pw l_shind_manuf_cbp foreignratio"
macro define political "repratio08 repratio12 repratio16 rep_primary_trump_vs sanders_vote_prop sendem houdem"

by group, sort: sum $demographic $political






